<html>
<head>
    <meta charset="utf-8"/>
    <title>ofd.js Demo</title>

    <style type="text/css">
        body {
            font-family: sans-serif;
            background-color: #ceedf4;
            margin: 0;
            padding: 0;
            color: rgb(51, 51, 51);
        }

    </style>

    <script type="text/javascript" src="./OfdParser.js"></script>
    <script type="text/javascript" src="./FreetypeKit.js"></script>
    <script type="text/javascript" src="https://unpkg.com/ofd.js"></script>
    <script type="text/javascript">
        function handleFiles(file) {
            console.log(file[0])
            ofd.parseOfdDocument({
                ofd: file[0],
                success(res) {
                    console.log(res)
                    const scale = (960 / 210).toFixed(1);
                    ofd.setMaxPageScale(scale * 4);
                    ofd.setPageScale(scale);
                    const divs = ofd.renderOfd(res.data.ofd, 0);
                    let contentDiv = document.getElementById('content');
                    contentDiv.innerHTML = '';
                    for (const div of divs) {
                        contentDiv.appendChild(div)
                    }
                }
            })
        }

    </script>
</head>
<body>

<h1>ofd.js demo</h1>

<input type="file"
       id="avatar" name="ofd文件"
       accept="ofd" onchange="handleFiles(this.files)">
<div id="content"/>
</body>
</html>
